﻿namespace VaccinationHost.Model
{
    /// <summary>
    /// 身份数据
    /// </summary>
    public class ClaimData
    {
        /// <summary>
        ///用户Id
        /// </summary>
        public Guid UserId { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string? UserName { get; set; } 
        /// <summary>
        /// 微信openId
        /// </summary>
        public string? OpenId { get; set; }
        /// <summary>
        /// 根据内容解析身份数据
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static ClaimData GetValue(string content)
        {
            if(string.IsNullOrWhiteSpace(content))
            {
                return null;
            }
            ClaimData claimData = new ClaimData();
            string[] arr = content.Split("|_|");

            claimData.OpenId= arr[0];
            claimData.UserId= Guid.Parse(arr[1]);
            claimData.UserName= arr[2];

            return claimData;
        }
    }
}
